<?php 
include '../data/data.php';
$title=$_POST['title'];  //标题
$content=$_POST['content']; //内容
$type=$_POST['type']; //类型
$user=$_SESSION['user']; //用户名
$date=date("Y-m-d");  //时间
if($type==''){
    $returndata = array("code"=>200,"msg"=>"参数错误","fwd"=>"");
    exit(json_encode($returndata));
}
if($user==''){
    $returndata = array("code"=>200,"msg"=>"参数错误","fwd"=>"");
    exit(json_encode($returndata));
}
if($type!=''){
  $result= mysql_query("SELECT * FROM feed WHERE user='$user' and date='$date'", $link);  
$row = mysql_fetch_array($result);
if($row[id]!=''){
    $returndata = array("code"=>200,"msg"=>"每天仅可发布一条!","fwd"=>"");
    exit(json_encode($returndata));
}
  $result= mysql_query("INSERT INTO feed (userid, user, title, content, type, date) VALUES ('$dl', '$user', '$title', '$content', '$type', '$date')", $link);
  if($result){
  $returndata = array("code"=>200,"msg"=>"发表成功","fwd"=>"");
  exit(json_encode($returndata));
  }else{
    $returndata = array("code"=>200,"msg"=>"发表失败","fwd"=>"");
    exit(json_encode($returndata));
  }

}
?>
